package com.lancoo.taskerdemo.image;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.ImageView;

import com.lancoo.lancooimageloader.LancooImageCallback;
import com.lancoo.lancooimageloader.LancooImageLoader;
import com.lancoo.lancooimageloader.LancooImageOptions;
import com.lancoo.taskerdemo.R;

/**
 * Author: Andecy
 * Time: 2017/5/11
 * Email: andecy@foxmail.com
 * Description: TODO
 */

public class ImageDemoActivity extends Activity {

    private static final String TAG = "ImageDemoActivity";


    private ImageView iv_demo_loader;

    public static void start(Context context) {
        Intent starter = new Intent(context, ImageDemoActivity.class);
        context.startActivity(starter);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_demo_image);
        initView();
    }

    private void initView() {
        iv_demo_loader = (ImageView) findViewById(R.id.iv_demo_loader);

        String url = "http://pic.wanmeiyueyu.com/Data/APPINFOR/32/96/yuanshichang.com.emoji2/BigIcon_1415289600.jpg";

        LancooImageOptions options = new LancooImageOptions.Builder()
                .setIgnoreGif(false)
                .setLoadingDrawable(R.mipmap.ic_gif)
                .setFailureDrawable(R.mipmap.ic_gif)
                .build();


        LancooImageCallback callback = new LancooImageCallback() {
            @Override
            public void onSuccess(Drawable result) {
                Log.w(TAG, "onSuccess");
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                Log.w(TAG, "onError-->" + ex.getMessage());
            }

            @Override
            public void onCancelled(CancelledException cex) {
                Log.w(TAG, "onCancelled");
            }

            @Override
            public void onFinished() {
                Log.w(TAG, "onFinished");
            }
        };


        LancooImageLoader.image().load(iv_demo_loader, url);
    }
}
